﻿@using Microsoft.AspNet.Identity

@{ 
    var profileUrl = Url.Content("~/img/user.jpg");
}

@if (Request.IsAuthenticated)
{
    <!-- User Account Menu -->
    <li class="dropdown user user-menu">
        <!-- Menu Toggle Button -->
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            <!-- The user image in the navbar-->
            <img src="@profileUrl" class="user-image" alt="User Image">
            <!-- hidden-xs hides the username on small devices so only the image appears. -->
            <span class="hidden-xs"><strong>@User.Identity.GetUserName()</strong></span>
        </a>
        <ul class="dropdown-menu">
            <!-- The user image in the menu -->
            <li class="user-header">
                <img src="@profileUrl" class="img-circle" alt="User Image">
                <p>
                    <strong>@User.Identity.GetUserName()</strong>
                    @{
                        string roleNameString = "&nbsp;";
                        List<string> userRoles = ((System.Security.Claims.ClaimsIdentity)User.Identity).Claims
                                        .Where(c => c.Type == System.Security.Claims.ClaimTypes.Role)
                                        .Select(c => c.Value).ToList();
                        if (userRoles != null && userRoles.Count() > 0)
                        {
                            roleNameString = userRoles[0];
                        }
                    }
                    <small><strong>@roleNameString</strong></small>
                </p>
            </li>
            <!-- Menu Footer-->
            <li class="user-footer">
                <div class="pull-left">
                    <a href="@Url.Action("ChangePassword", "Manage")" class="btn btn-default btn-flat">Manage</a>
                </div>
                <div class="pull-right">
                    @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
                    {
                        @Html.AntiForgeryToken()
                        <a href="javascript:document.getElementById('logoutForm').submit()" class="btn btn-default btn-flat">Sign Out</a>
                    }
                </div>
            </li>
        </ul>
    </li>
}
else
{
    <!--User Account Menu -->
    <li class="dropdown user user-menu">
        <!-- Menu Toggle Button -->
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            <!-- The user image in the navbar-->
            <img src="@profileUrl" class="user-image" alt="User Image">
            <!-- hidden-xs hides the username on small devices so only the image appears. -->
            <span class="hidden-xs"><strong>Sign In</strong></span>
        </a>
        <ul class="dropdown-menu">
            <!-- The user image in the menu -->
            <li class="user-header">
                <img src="@profileUrl" class="img-circle" alt="User Image">
                <p>
                    Sign In
                    <small>to continue</small>
                </p>
            </li>
            <!-- Menu Footer-->
            <li class="user-footer">                
                <div class="pull-left">
                </div>
                <div class="pull-right">
                    <a href="@Url.Action("Login","Account")" class="btn btn-default btn-flat">Sign In</a>
                    @*<a href="@Url.Action("Register","Account")" class="btn btn-default btn-flat">Register</a>*@
                </div>
            </li>
        </ul>
    </li>
}